home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
ASSEMBLE
/
0938.ZIP
/
KEGELUNX.ARC
/
PROT.ASM
< prev
next >
Wrap
Assembly Source File
|
1985-06-10
|
2KB
|
116 lines
page 66,132
;compressed mode on prn.
page
;---- (un)prot.com ------------------------------------------------
; Usage: (un)prot filespec
; Write-protects (unprotects) filespec
; Wildcards allowed in filename
; MCN 10 July 84
; DRK 29 July 84- to use new args, ffind; old DTA was getting clobbered?
;---------------------------------------------------------------
extrn _args:near,argc:word,argv:word
extrn ffirst:near,fnext:near,fnam:byte,finder:word
stderr equ 2
code segment public 'CODE'
assume cs:code,ds:code,es:code
f_attrib equ 21 ; offset from DTA of file attrib
org 100h
; This is a .COM program.
; It takes one argument- the name of a file (wildcards ok).
;
; The argument is the first nonblank string of chars.
; Either backslashes or forward slashes may be used in a pathname.
exist proc near
; Get arguments.
call _args
; Check # of arguments- if not exactly one, send usage message.
cmp argc,1
jnz usage
; call DOS to see if file exists.
mov dx, argv[2] ; get pointer to first argument.
mov cx, 0 ; no special attribute bits set
call ffirst ; FIND FIRST
jc nofile ; if carry set, no file found.
doit:
mov bx, finder
mov cl, [bx][f_attrib]
or cl, 1 ; write protect
mov ax, 4301h ; put file mode
lea dx, fnam ;
int 21h
next: call fnext ; FIND NEXT
jnc doit ; again
mov al, 0 ; errorlevel= 0 => file found
jmp short exit
nlen = 0
nlen = nend-noff
nofile: mov bx, stderr ; error device
mov cx, nlen
mov dx, offset nmsg
mov ah, 40h
int 21h
mov al, 1 ; file not found error
jmp short exit
exit: mov ah, 4ch
int 21h ; terminate process, return status in AL.
ulen = 0
ulen = uend-uoff
usage: mov bx, stderr ; write to error device...
mov cx, ulen
mov dx, offset umsg
mov ah, 40h
int 21h
mov al, 2 ; error2 = syntax error
jmp exit
nfw:
blam: mov bx, stderr ; error device
mov cx, nlen
mov dx, offset nmsg
mov ah, 40h
int 21h
mov al, 0ffh ; file whiz error
jmp exit
exist endp
handle dw ?
umsg db 'Usage: prot filespec', 13, 10
bugo db ?
uoff equ offset umsg
uend equ offset bugo
nmsg db 'File not found', 13, 10
nugo db ?
noff equ offset nmsg
nend equ offset nugo
code ends
end exist